package tgc.edu.tms.entity;


import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import com.mysql.fabric.xmlrpc.base.Data;

import tgc.edu.tms.custom.BaseEntity;

/***
 * 
 * 授课日志
 *
 */
@Entity
public class Teaching extends BaseEntity<Integer> {

	private String time;//时间
	private ClassSchedule kc;// 课表
	private String number;// 上课人数
	private Teachingplan teachingplan;//上课内容
	private String working;// 工作量
	private String absence;// 缺勤人数
	private String remark;// 备注
	

	//节次
	@Transient
	public String getJcsj() {
		return kc.getJcb().getJcsj();
	}
	
	//授课内容
	@Transient
	public String getContent() {
		return teachingplan==null?null:teachingplan.getContent();
	}
	
	//教师名称
	@Transient
	public String getName() {
		return teachingplan==null?null:teachingplan.getTeacherName();
	}
	
	//课程课程
	@Transient
	public String getKcmc() {
		return teachingplan==null?null:teachingplan.getName();
	}
	
	/**
	 * 
	 * @return星期
	 */
	@Transient
	public String getWeekDay() {
		try {
			DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
			Date date = format.parse(time);
			Instant instant = date.toInstant();
			ZoneId zoneId = ZoneId.systemDefault();
			LocalDate localDate = instant.atZone(zoneId).toLocalDate();
			DayOfWeek day = localDate.getDayOfWeek();
			String WeekDay = "";

	            switch (day)
	            {                                                                              

	                case MONDAY:

	                    WeekDay = "星期一";

	                    break;

	                case FRIDAY:

	                    WeekDay = "星期五";

	                    break;

	                case SATURDAY:

	                    WeekDay = "星期六";

	                    break;

	                case SUNDAY:

	                    WeekDay = "星期日";

	                    break;

	                case THURSDAY:

	                    WeekDay = "星期四";

	                    break;

	                case TUESDAY:

	                    WeekDay = "星期二";

	                    break;

	                case WEDNESDAY:

	                    WeekDay = "星期三";

	                    break;

	            }

	            
			return WeekDay;
		} catch (ParseException e) {
			return "报错了";
		}
		 
	}
	
	
	
	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	@ManyToOne
	public ClassSchedule getKc() {
		return kc;
	}

	public void setKc(ClassSchedule kc) {
		this.kc = kc;
	}
	
	@Transient
	public String getTeacherName() {
		return kc.getEp().getTeacher().getName();
	}
	
	@Transient
	public String getTbClassName() {
		return kc.getTbclassName();
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}
	
	@ManyToOne
	public Teachingplan getTeachingplan() {
		return teachingplan;
	}

	public void setTeachingplan(Teachingplan teachingplan) {
		this.teachingplan = teachingplan;
	}

	public String getWorking() {
		return working;
	}

	public void setWorking(String working) {
		this.working = working;
	}

	public String getAbsence() {
		return absence;
	}

	public void setAbsence(String absence) {
		this.absence = absence;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

}
